<template>
	<view>
		<view class="home_content2" @click="xiugaimima">
			<view class="textpadd" >
				修改登陆密码
			</view>
			<view class="">
				<image src="/static/images/next.png" mode="" style="width: 20px;height: 20px;"></image>
			</view>
		</view>
		<view class="home_content2" @click="zhifumima">
			<view class="textpadd">
				支付密码
			</view>
			<view class="" >
				<image src="/static/images/next.png" mode="" style="width: 20px;height: 20px;"></image>
			</view>
		</view>
		<view class="home_content2" >
			<view class="textpadd">
				声音提醒
			</view>
			<view class="">
			<switch @change="switch2Change1" :checked="audio" />
			</view>
		</view>
		
		<view class="home_content2" @click="fankui">
			<view class="textpadd">
				意见反馈
			</view>
			<view class="">
				<image src="/static/images/next.png" mode="" style="width: 20px;height: 20px;"></image>
			</view>
		</view>

		<view class="home_content4" @click="guanyu">
			<view class="textpadd">
				版本更新
			</view>
			<view class="" style="display: flex;flex-direction: row;flex-wrap: nowrap;">
				<text style="font-size: 11px; color: #C0C0C0;">最新版本1.0</text>
				<image src="/static/images/next.png" mode="" style="width: 20px;height: 20px;"></image>
			</view>
		</view>
		<view class="home_content2" @click="zhuxiao">
			<view class="textpadd">
				注销账号
			</view>
			<view class="">
				<image src="/static/images/next.png" mode="" style="width: 20px;height: 20px;"></image>
			</view>
		</view>
		<view style="text-align: center;margin: 0 auto;margin-top: 20%;height: 50px;background-color: #FFFFFF;line-height: 50px;" @click="tuichu">安全退出</view>
	</view>
</template>

<script>
	let WebIM = require("../../utils/WebIM")["default"];
	let disp = require("../../utils/broadcast");
	export default {
		data() {
			return {
				audio:false
			}
		},
		onLoad() {
			this.audio=uni.getStorageSync('audio')
		},
		methods: {
			switch2Change1(e){
				console.log(e)
				if(e.detail.value==true){
					this.audio = e.detail.value
					uni.setStorageSync('audio',this.audio)
					uni.showToast({
						title:'开启成功',
						icon:'none'
					})
				}else{
					this.audio = e.detail.value
					uni.setStorageSync('audio',this.audio)
					uni.showToast({
						title:'关闭成功',
						icon:'none'
					})
				}
			},
			zhuxiao(){
				let _this = this
				let token = uni.getStorageSync("token")
				uni.showModal({
					title:"确定注销账号,不可撤回的操作",
					success:function(res){
						if(res.confirm){
							uni.request({
								url: _this.G_base + '/api/logOff',
								method: "GET",
								header: {
									'content-type': 'application/x-www-form-urlencoded',
									'Authori-zation': 'Bearer ' + token
								},
								success: (res) => {
									console.log(res)
									if (res.data.status == 200) {
										uni.showToast({
											title: "注销成功"
										}) 
										uni.clearStorageSync()
										setTimeout(() => {
											uni.reLaunch({
												url: "/pages/login/newlogin"
											})
										}, 1000)
										WebIM.conn.close();
									}
								},
								fail: (err) => {
									console.log(err)
								}
							});
						}
					}
				})
			},
			zhifumima(){
				uni.navigateTo({
					url:"/pages/userperson/userperson"
				})
			},
			xiugaimima() {
				uni.navigateTo({
					url: "/pages/userperson/userlogin"
				})
			},
			test() {
				uni.navigateBack({
					delta:1
				})
			},
			goinfo(){
				uni.navigateTo({
					url:"zhanghao"
				})
			},
			fankui(){
				uni.navigateTo({
					url:"../help/help"
				})
			},
			guanyu(){
				uni.navigateTo({
					url:"../Aboutus/Aboutus"
				})
			},
			tuichu() {
				let _this = this
				let token = uni.getStorageSync("token")
				uni.showModal({
				  title: "是否退出登录",
				  success: function (res) {
				    if (res.confirm) {
						console.log("退出")
						uni.request({
							url: _this.G_base + '/api/logout',
							method: "GET",
							header: {
								'content-type': 'application/x-www-form-urlencoded',
								'Authori-zation': 'Bearer ' + token
							},
							success: (res) => {
								console.log(res)
								if (res.data.status == 200) {
									uni.showToast({
										title: "退出成功"
									}) 
									uni.clearStorageSync()
									setTimeout(() => {
										uni.reLaunch({
											url: "/pages/login/newlogin"
										})
									}, 1000)
									WebIM.conn.close();
								}
							},
							fail: (err) => {
								console.log(err)
							}
						});
	
				    }
				  }
				});	
			}
		},
	}
</script>

<style scoped>
	page{
		background-color: #FAFAFA;
	}
	.textpadd{
		padding: 10px 0;
		font-size: 16px;
	}
	.hrxian {
		width: 92%;
		margin: 2px 4%;
	}

	.home_content image {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.home_content {
		margin: 10px 10px;
		border-bottom: 1px solid #EEEEEE;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.home_content2 image {
		display: flex;
		justify-content: center;
		align-items: center;
		
	}
	
	.home_content2 {
		padding: 10px 10px;
		border-bottom: 1px solid #EEEEEE;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #FFF;
	}
	.home_content3 image {
		display: flex;
		justify-content: center;
		align-items: center;
	}
	
	.home_content3 {
		margin: 10px 10px;
		border-bottom: 1px solid #EEEEEE;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.home_content4 image {
		display: flex;
		justify-content: center;
		align-items: center;
	}
	
	.home_content4 {
		background-color: #FFF;
		padding: 10px 10px;
		border-bottom: 1px solid #EEEEEE;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
</style>
